// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    //LIFE-CYCLE CALLBACKS:

    all: cc.Node = null;    
onLoad(){
    this.all = cc.find('Canvas/气泡框3/body/心脏');
    this.all.on(cc.Node.EventType.TOUCH_START, this.barLoading, this)    
    this.all.on(cc.Node.EventType.TOUCH_END, this.barStopping, this)    
}

//开始渲染彩条图片
barLoading(){
    this.BarPress();       
    cc.log("图片已渲染");
}
//停止渲染+初始化
barStopping(){
    cc.log("已停止");
    this.initPress();
}

BarPress(){
    this.schedule(this.BarPress, 0.015);//每隔x秒加下面n的进度
    this.node.getComponent(cc.Sprite).fillRange += 0.03;//每x秒所增加的环形百分比
    if (this.node.getComponent(cc.Sprite).fillRange >= 1) {
        this.unschedule(this.BarPress);
    }
}
initPress(){
    this.node.getComponent(cc.Sprite).fillRange =0;
    this.unschedule(this.BarPress);

    cc.log("图片已初始化为空");
}
    start () {

    }

    // update (dt) {}
}